home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 2000 July / macformat-092.iso / Fireworks 3 / Settings / HTML Code / GoLive / slices.htt < prev   
Encoding:
Text File  |  1999-11-19  |  39.7 KB  |  1,279 lines

  1. // Fireworks GoLive 4 and Cyberstudio 3.1  HTML & JavaScript for sliced output.
  2. // Version 3.0 09SEP99
  3.  
  4. // To export HTML without comments change the value of variable doComments to "false".
  5. var doComments=true;
  6. var indentNestedImagemaps=false;
  7.  
  8.  
  9.  
  10. // When doComments is set to "true" the WRITE_HTML_COMMENT and WRITE_JS_COMMENT functions
  11. // include HTML and JavaScript comments in the exported file.
  12. function WRITE_HTML_COMMENT(str) {
  13.     if (doComments) WRITE_HTML("<!--"+str+"-->\n");
  14. }
  15.  
  16. function WRITE_JS_COMMENT(str) {
  17.     if (doComments) WRITE_HTML("/* "+str+" */\n");
  18. }
  19.  
  20. function Fix(href)
  21. {
  22.     // change C|/ to C:/  jba
  23.     var re = /\|\//i;
  24.  
  25.     href = href.toString().replace(re, ":/");
  26.     return(href);
  27. }
  28.  
  29. var doHeader = true;
  30. doHeader = exportDoc.generateHeader; 
  31. // When HTML is generated to a file, generateHeader is true.
  32. // When HTML is generated for the clipboard, 
  33. // generateHeader is false.
  34.  
  35. // These are the suffixes for the first 4 frames
  36. var sfx = new Array();
  37. sfx[0] = "";        // first frame doesn't normally have a suffix.
  38. sfx[1] = "_f2";        // second frame.
  39. sfx[2] = "_f3";        // third frame.
  40. sfx[3] = "_f4";        // fourth frame.
  41. var numSFX = 4;
  42. function UpdateFileNames(curSlices) {
  43.     for (var curRow = 0; curRow < curSlices.numRows; curRow++) {
  44.         for (var curCol = 0; curCol < curSlices.numColumns; curCol++) {
  45.             if (curSlices[curRow][curCol].skipCell) continue;
  46.             var nestedTable = curSlices[curRow][curCol].nestedTableSlices;
  47.             if (nestedTable) {
  48.                 UpdateFileNames(nestedTable);
  49.                 continue;
  50.             }
  51.             var curSlice = curSlices[curRow][curCol];
  52.             var cellName = "";
  53.             if (curSlice && curSlice.getFrameFileName(0)) {
  54.                 cellName = curSlice.getFrameFileName(0).toString();
  55.                 var i;
  56.                 var limit = exportDoc.numFrames;
  57.                 if (limit > numSFX) limit = numSFX;
  58.                 for (i=0; i<limit; i++) {
  59.                     if (curSlice.getFrameFileName(i)) {
  60.                         curSlice.setFrameFileName(i, cellName + sfx[i]);
  61.                     }
  62.                 }
  63.             }
  64.         }
  65.     }
  66. }
  67. UpdateFileNames(slices);
  68.  
  69. var d = new Date();
  70. if (doHeader) {
  71.     WRITE_HTML("<html>\n");
  72.     WRITE_HTML("\n");
  73.     WRITE_HTML("    <head>\n");
  74.  
  75.     WRITE_HTML("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=");
  76.     var charSet = "";
  77.     if (App) charSet = App.getPref("HtmlCharSet");
  78.     if (charSet == "") charSet = "iso-8859-1";
  79.     WRITE_HTML(charSet + "\">\n"); 
  80.     WRITE_HTML("<meta name=\"description\" content=\"Fireworks Splice HTML\">\n");
  81.  
  82.     // Use Base Name from export dialog as document title.
  83.     WRITE_HTML("<title>", exportDoc.filename, "</title>\n");
  84.     WRITE_HTML("<csscriptdict>\n");
  85.     WRITE_HTML("    <script><!--\n");
  86.     WRITE_HTML("\n");
  87. }
  88. WRITE_HTML("<!-- Fireworks 3.0  GoLive 4/Cyberstudio 3.1 target.  Created ", d, " -->\n");
  89. WRITE_HTML("\n");
  90.  
  91. var curIdCounter = d.getTime() & 0x7FFFF000;
  92.  
  93. // Function cellName determines the name for the image in a particular table cel
  94. // cellName is based off of the slice name if one was specified. Otherwise the
  95. // Base file name from the export dialog is used.
  96. function CellName(curSlices, row, col) {
  97.     var curSlice = curSlices[row][col];
  98.     var cellName = "";
  99.     if (curSlice && curSlice.getFrameFileName(0)) {
  100.         cellName = curSlice.getFrameFileName(0).toString();
  101.         curSlice.setFrameFileName(0, cellName);
  102.         // remove illegal characters
  103.         cellName = cellName.replace(/\W/g, "");
  104.         // if it starts with a number, add N to the front.
  105.         if (cellName == "") cellName = "n" + exportDoc.imagename + "_" + (row+1) + "_" + (col+1);
  106.         if (cellName.search(/\d/) == 0) {
  107.             cellName = "n"+cellName;
  108.         }
  109.     }
  110.     if (cellName!="") return(cellName);     
  111.  
  112.     var prefix;
  113.     if (!curSlices) return("nullCellName");
  114.     if (curSlices.id == 0) {
  115.         prefix = "";
  116.     } else {
  117.         prefix = curSlices.id+"_";
  118.     }
  119.     var suffix="";
  120.     if (curSlices.numRows > 1 || curSlices.numColumns > 1) {
  121.         suffix = "_" + (row+1) + "_" + (col+1);
  122.     }
  123.     cellName = "n" + prefix + exportDoc.imagename + suffix;
  124.     return(cellName);
  125. }
  126.  
  127.  
  128.  
  129. // Declare variables for processing Behaviors.    
  130. var kActionStatusMessage = 1;
  131. var kActionSwapImage = 2;
  132. var kActionButtonDown = 4;
  133. var kActionSwapImageRestore = 5;
  134. var kActionButtonHighlight = 6; 
  135. var kActionButtonRestore = 7;
  136.  
  137.  
  138. var kEventMouseOver = 0;
  139. var kEventOnClick = 1;
  140. var kEventMouseOut = 2;
  141. var kEventOnLoad = 3;
  142.  
  143.  
  144. var hasAnyButtons = false;
  145. var needsPreloads = false;
  146.  
  147. function IsSwap(curBeh) {
  148.     if (curBeh.action == kActionButtonHighlight ||
  149.         curBeh.action == kActionSwapImage ||
  150.         curBeh.action == kActionButtonDown) {
  151.         return(true);
  152.     }
  153.     return(false);
  154. }
  155.  
  156. function DoRestore(curBeh) {
  157.     if (curBeh.action == kActionButtonHighlight) return(true);
  158.     return(curBeh.restoreOnMouseout);
  159. }
  160.  
  161. function DoFile(curBeh) {
  162.     var swapRow = curBeh.targetRowNum;
  163.     var swapCol = curBeh.targetColumnNum;
  164.     var swapFrame = curBeh.targetFrameNum; 
  165.     var swapTable = curBeh.targetTable;
  166.     if (!swapTable) return;
  167.  
  168.     var fileName = swapTable[swapRow][swapCol].getFrameFileName(0);
  169.     if (curBeh.downHighlight && curBeh.hasDhTargetFrame) {
  170.         var fm = curBeh.dhTargetFrameNum;
  171.         if (!swapTable[swapRow][swapCol].getFrameFileName(fm)) {
  172.             var tmp;
  173.             var frame = fm+1;
  174.             if (fm < 4) {
  175.                 tmp = fileName + sfx[fm];
  176.             } else {
  177.                 tmp = fileName + "_f" + frame;
  178.             }
  179.             swapTable[swapRow][swapCol].setFrameFileName(fm, tmp);
  180.         }
  181.     }
  182.     if (curBeh.hasTargetFrame && swapFrame > 0) {
  183.         if (!swapTable[swapRow][swapCol].getFrameFileName(swapFrame)) {
  184.             var frame = swapFrame + 1;
  185.             if (swapFrame < 4) {
  186.                 fileName = fileName + sfx[swapFrame];
  187.             } else {
  188.                 fileName = fileName + "_f" + frame;
  189.             }
  190.             swapTable[swapRow][swapCol].setFrameFileName(swapFrame, fileName);
  191.         }
  192.     } 
  193.     if (curBeh.preload) {
  194.         DoPreload(curBeh);
  195.     }
  196. }
  197.  
  198. function DoPreload(curBeh) {
  199. }
  200.  
  201. function CheckFileAndPreloads(curSlices) {
  202.  
  203.     for (var curRow = 0; curRow < curSlices.numRows; curRow++) {
  204.         for (var curCol = 0; curCol < curSlices.numColumns; curCol++) {
  205.             var curSlice = curSlices[curRow][curCol];
  206.             if (curSlice.skipCell) continue;
  207.             var nestedTable = curSlices[curRow][curCol].nestedTableSlices;
  208.             if (nestedTable) {
  209.                 CheckFileAndPreloads(nestedTable);
  210.                 continue;
  211.             }
  212.             if (curSlice.behaviors.numberOfBehaviors > 0) {
  213.                 var behaviors = curSlices[curRow][curCol].behaviors;
  214.                 for (var i=0; i<behaviors.numberOfBehaviors; i++) {
  215.                     var curBehavior = behaviors[i];
  216.                     curBehavior.id = curIdCounter;
  217.                     curIdCounter+=2; // restore behavior is this + 1.
  218.                     DoFile(curBehavior);
  219.                     if (IsSwap(curBehavior)) {
  220.                         if (curBehavior.hasTargetFrame && curBehavior.targetFrameNum==1 && curBehavior.event == kEventMouseOver) {
  221.                             //alert(" "+curRow+","+curCol+", tgt "+curBehavior.targetRowNum+","+curBehavior.targetColumnNum);
  222.                             if (curRow == curBehavior.targetRowNum && curCol == curBehavior.targetColumnNum && curSlices==curBehavior.targetTable) {
  223.                                 curSlices[curRow][curCol].isButton = true;
  224.                             }
  225.                         }
  226.                     }
  227.                 }
  228.             }
  229.             var imagemap = curSlice.imagemap;
  230.             
  231.             for (var j=0; j < imagemap.numberOfURLs; j++) {
  232.                 curSlice.isButton = false;  // imagemaps aren't buttons.  jba.                
  233.                 var curImagemap = imagemap[j];
  234.                 var behaviors = curImagemap.behaviors;
  235.                 curImagemap.modBehaviors = behaviors; // Need to save a copy for obscure reasons.  jba.
  236.                 for (var i=0; i<behaviors.numberOfBehaviors; i++) {
  237.                     var curBehavior = behaviors[i];
  238.                     DoFile(curBehavior);
  239.                     curBehavior.id = curIdCounter;
  240.                     curIdCounter+=2; // restore behavior is this + 1.
  241.                     if (IsSwap(curBehavior)) {
  242.                         DoFile(curBehavior);
  243.                     }
  244.                 }
  245.             }
  246.             if (curSlice.isButton) {
  247.                 hasAnyButtons = true;
  248.             }
  249.         }
  250.     }
  251.  
  252. }
  253.  
  254. CheckFileAndPreloads(slices);
  255.  
  256. var csAct = "";
  257. var csactionsStr = "";
  258. var csactionItem = ""
  259.  
  260. var dirPath = Fix(slices.imagesDirPath);
  261.  
  262.  
  263. function DoFileAndPreloads(curSlices) {
  264.     for (var curRow = 0; curRow < curSlices.numRows; curRow++) {
  265.         for (var curCol = 0; curCol < curSlices.numColumns; curCol++) {
  266.             var curSlice = curSlices[curRow][curCol];
  267.             if (curSlice.skipCell) continue; 
  268.             var nestedTable = curSlices[curRow][curCol].nestedTableSlices;
  269.             if (nestedTable) {
  270.                 DoFileAndPreloads(nestedTable);
  271.                 continue;
  272.             }
  273.             curSlice.overAction = "";
  274.             curSlice.outAction = "";
  275.             curSlice.clickAction = "";
  276.             curSlice.csover = "";
  277.             curSlice.csout = "";
  278.             curSlice.csclick = "";
  279.             if (!curSlice.isButton) continue;
  280.             var cellName = CellName(curSlices, curRow,curCol);            
  281.             var button = new Object;
  282.             button.name = cellName;
  283.             var upFrame = 0;
  284.             if (slices.doDemoHTML && slices.demoIndex>0 && 
  285.                 slices.demoIndex == curSlice.downIndex) {
  286.                 upFrame = 2;
  287.             } 
  288.  
  289.             button.up = "'"+dirPath + curSlice.getFrameFileName(upFrame) + curSlice.imageSuffix + "'";
  290.             button.over = "''";
  291.             button.hit = "''";
  292.             button.status = "";
  293.             if (curSlice.hasAltText) {
  294.                 button.status = curSlice.altText;
  295.             } 
  296.             var behaviors =curSlice.behaviors;
  297.             for (var i=0; i<behaviors.numberOfBehaviors; i++) {
  298.                 var curBehavior = behaviors[i];
  299.                 if (curBehavior.action == kActionStatusMessage) {
  300.                     var hexName = curBehavior.id.toString(16);
  301.                     if (curBehavior.event == kEventMouseOver) {
  302.                         button.status = curBehavior.statusText;
  303.                         curBehavior.ateTheBehavior = true;
  304.                     } else {                    
  305.                         // CSAct['B2C231A71'] = new Array(CSSetStatus,' ');
  306.                         /* Generate a csact entry */
  307.                         var curAction = "CSAct['" + hexName + "'] = new Array(CSSetStatus,";
  308.                         curAction += "'" + curBehavior.statusText + "');\n";
  309.                         csAct += curAction;
  310.                         // <csaction name="B2C231A71" class="Set Status" val0=" ">
  311.                         curAction = "    <csaction name=\"" + hexName + "\" class=\"Set Status\" val0=\"" ;
  312.                         curAction += curBehavior.statusText + "\">\n"
  313.                         csactionsStr += curAction;
  314.                         if (curBehavior.event == kEventOnClick) {
  315.                             if (curSlice.csclick != "") curSlice.csclick += ",";
  316.                             curSlice.csclick += hexName;
  317.                             if (curSlice.clickAction != "") curSlice.clickAction += ",";
  318.                             curSlice.clickAction += "'"+hexName+"'";
  319.                         }
  320.                         if (curBehavior.event == kEventMouseOut) {
  321.                             if (curSlice.csout != "") curSlice.csout += ",";
  322.                             curSlice.csout += hexName;
  323.                             if (curSlice.outAction != "") curSlice.outAction += ",";
  324.                             curSlice.outAction += "'"+hexName+"'";
  325.                         } 
  326.                     }
  327.                 }
  328.     
  329.                 if (IsSwap(curBehavior)) {
  330.                     var swapRow = curBehavior.targetRowNum;
  331.                     var swapCol = curBehavior.targetColumnNum;
  332.                     var swapTable = curBehavior.targetTable;
  333.                     if (swapRow == curRow && swapCol == curCol && swapTable == curSlices) {
  334.                         if (curBehavior.hasHref) {
  335.                             fileName = curBehavior.href;
  336.                         } else {
  337.                             fileName = dirPath + curSlice.getFrameFileName(curBehavior.targetFrameNum) + curSlice.imageSuffix;
  338.                         }
  339.                         if (curBehavior.event == kEventMouseOver) {
  340.                             button.over = "'"+fileName+"'";
  341.                             curBehavior.ateTheBehavior = true;
  342.                         } 
  343.                         if (curBehavior.event == kEventOnClick) {
  344.                             button.hit = "'"+fileName+"'";
  345.                             curBehavior.ateTheBehavior = true;
  346.                         }
  347.                         if (curBehavior.event == kEventMouseOut) {
  348.                             curBehavior.ateTheBehavior = true;
  349.                         }
  350.                     } 
  351.                     if (!curBehavior.ateTheBehavior) {
  352.                         curRestore = DoRestore(curBehavior);
  353.                         var swapRow = curBehavior.targetRowNum;
  354.                         var swapCol = curBehavior.targetColumnNum;
  355.                         var swapFrame = curBehavior.targetFrameNum; 
  356.                         var swapTable = curBehavior.targetTable;
  357.                         var fileName;
  358.                         if (curBehavior.hasHref) {
  359.                             fileName = curBehavior.href;
  360.                         } else {
  361.                             fileName = dirPath + swapTable[swapRow][swapCol].getFrameFileName(swapFrame) + swapTable[swapRow][swapCol].imageSuffix;
  362.                         }
  363.                         var hexName = curBehavior.id.toString(16);
  364.                         var cellName = CellName(swapTable, swapRow,swapCol);
  365.                         //CSAct['B2DB1B0B1'] = new Array(CSSetImageURL,'RalphTheImage_mtv',/*URL*/ 'mtv_F3.gif');
  366.                         /* Generate a csact entry */
  367.                         var curAction = "CSAct['" + hexName + "'] = new Array(CSSetImageURL,";
  368.                         // target name
  369.                         curAction += "'" + cellName + "',/*URL*/ '" + fileName + "');\n";
  370.                         csAct += curAction;
  371.                         // <csaction name="B2DB1B0B1" class="Set Image URL" val0="RalphTheImage_mtv" val1="mtv_F3.gif">
  372.                         curAction = "            <csaction name=\"" + hexName + "\" class=\"Set Image URL\" val0=\"" ;
  373.                         curAction += cellName+"\" val1=\"" + fileName + "\">\n"
  374.                         csactionsStr += curAction;
  375.                         if (curBehavior.event == kEventMouseOver) {
  376.                             if (curSlice.csover != "") curSlice.csover += ",";
  377.                             curSlice.csover += hexName;
  378.                             if (curSlice.overAction != "") curSlice.overAction += ",";
  379.                             curSlice.overAction += "'"+hexName+"'";
  380.                         } 
  381.                         if (curBehavior.event == kEventOnClick) {
  382.                             if (curSlice.csclick != "") curSlice.csclick += ",";
  383.                             curSlice.csclick += hexName;
  384.                             if (curSlice.clickAction != "") curSlice.clickAction += ",";
  385.                             curSlice.clickAction += "'"+hexName+"'";
  386.                         }
  387.                         if (curBehavior.event == kEventMouseOut) {
  388.                             if (curSlice.csout != "") curSlice.csout += ",";
  389.                             curSlice.csout += hexName;
  390.                             if (curSlice.outAction != "") curSlice.outAction += ",";
  391.                             curSlice.outAction += "'"+hexName+"'";
  392.                         } else if (curRestore) {
  393.                             hexName = (curBehavior.id+1).toString(16);
  394.                             fileName = dirPath + swapTable[swapRow][swapCol].getFrameFileName(0) + swapTable[swapRow][swapCol].imageSuffix;
  395.                             /* Generate a csact entry */
  396.                             var curAction = "CSAct['" + hexName + "'] = new Array(CSSetImageURL,";
  397.                             // target name
  398.                             curAction += "'" + cellName + "',/*URL*/ '" + fileName + "');\n";
  399.                             csAct += curAction;
  400.                             // <csaction name="B2DB1B0B1" class="Set Image URL" val0="RalphTheImage_mtv" val1="mtv_F3.gif">
  401.                             curAction = "            <csaction name=\"" + hexName + "\" class=\"Set Image URL\" val0=\"" ;
  402.                             curAction += cellName+"\" val1=\"" + fileName + "\">\n"
  403.                             csactionsStr += curAction;
  404.                             if (curSlice.csout != "") curSlice.csout += ",";
  405.                             curSlice.csout += hexName;
  406.                             if (curSlice.outAction != "") curSlice.outAction += ",";
  407.                             curSlice.outAction += "'"+hexName+"'";
  408.                         }
  409.                         
  410.                     }
  411.                 }
  412.             }
  413.  
  414.             if (curSlice.isButton) {
  415.                 curSlice.buttonStatus = button.status;
  416.                 if (doHeader) {
  417.                     WRITE_HTML("CSILoad('" +button.name +"',new Array(");
  418.                     WRITE_HTML("/*URL*/"+button.up+",/*URL*/"+button.over+",/*URL*/"+button.hit+",'"+button.status+"'));\n");
  419.                 }
  420.                 
  421.             }
  422.         }
  423.         
  424.     }
  425.  
  426. }
  427.  
  428. function WritePreloads(curSlices) {    
  429.     /* Write preloads */
  430.     for (var curRow = 0; curRow < curSlices.numRows; curRow++) {
  431.         for (var curCol = 0; curCol < curSlices.numColumns; curCol++) {
  432.             if (curSlices[curRow][curCol].skipCell) continue;
  433.             var nestedTable = curSlices[curRow][curCol].nestedTableSlices;
  434.             if (nestedTable) {
  435.                 WritePreloads(nestedTable);
  436.                 continue;
  437.             }
  438.             for (var curFrame = 0; curFrame < exportDoc.numFrames; curFrame++) {
  439.                 if (curSlices[curRow][curCol].isButton    && curFrame < 4 && curFrame != 2) {
  440.                     // Buttons preload their first 3 states.
  441.                     continue;
  442.                 }            
  443.                 var curFile = curSlices[curRow][curCol].getFrameFileName(curFrame);
  444.                 if (!curFile) continue;
  445.                 if (curFrame == 0 && !curSlices[curRow][curCol].isSwapped) continue;
  446.                 needsPreloads = true; // just in case.  
  447.                 var hexName = curIdCounter.toString(16);
  448.                 curIdCounter += 2;
  449.                 // CSAction(new Array('B31EB2911'));
  450.                 WRITE_HTML("CSAction(new Array('" + hexName + "'));\n");
  451.                 
  452.                 // CSAct['B31EB2911'] = new Array(CSPreloadImage,/*URL*/ 'ESPN_F2.gif');
  453.                 fileName = dirPath + curFile + curSlices[curRow][curCol].imageSuffix;
  454.                 var curAction = "CSAct['" + hexName + "'] = new Array(CSPreloadImage,/*URL*/ '";
  455.                 curAction += fileName + "');\n"
  456.                 csAct += curAction;
  457.                                         
  458.                 // <csaction name="B31EB2911" class="Preload Image" val0="ESPN_F2.gif">
  459.                 curAction = "    <csaction name=\"" + hexName + "\" class=\"Preload Image\" val0=\"" ;
  460.                 curAction += fileName + "\">\n"
  461.                 csactionsStr += curAction;
  462.                 
  463.                 //<csactionitem name="B31EB2911"></csactionitem>
  464.                 csactionItem += "    <csactionitem name=\"" + hexName + "\"></csactionitem>\n";
  465.                 
  466.             }
  467.         }
  468.     }        
  469.     
  470. }
  471.  
  472. if (hasAnyButtons || needsPreloads) {
  473.     if (doHeader) {
  474.         WRITE_HTML("function CSScriptInit() {\n");
  475.     }
  476.     DoFileAndPreloads(slices); 
  477.     if (doHeader) {
  478.         WritePreloads(slices);
  479.         WRITE_HTML("}\n");
  480.     }
  481. }
  482.  
  483. function DoBehavior(curSlices, curBehavior, parentObject) {
  484.     if (curBehavior.action == kActionStatusMessage) {
  485.         if (!curBehavior.id) {
  486.             alert(curBehavior + ", "+parentObject);
  487.         }
  488.         var hexName = curBehavior.id.toString(16);
  489.         curRestore = DoRestore(curBehavior);
  490.         // CSAct['B2C231A71'] = new Array(CSSetStatus,' ');
  491.         /* Generate a csact entry */
  492.         var curAction = "CSAct['" + hexName + "'] = new Array(CSSetStatus,";
  493.         curAction += "'" + curBehavior.statusText + "');\n";
  494.         csAct += curAction;
  495.         // <csaction name="B2C231A71" class="Set Status" val0=" ">
  496.         curAction = "            <csaction name=\"" + hexName + "\" class=\"Set Status\" val0=\"" ;
  497.         curAction += curBehavior.statusText + "\">\n"
  498.         csactionsStr += curAction;
  499.         if (curBehavior.event == kEventOnClick) {
  500.             if (parentObject.csclick != "") parentObject.csclick += ",";
  501.             parentObject.csclick += hexName;
  502.             if (parentObject.clickAction != "") parentObject.clickAction += ",";
  503.             parentObject.clickAction += "'"+hexName+"'";
  504.         }
  505.         if (curBehavior.event == kEventMouseOver) {
  506.             if (parentObject.csover != "") parentObject.csover += ",";
  507.             parentObject.csover += hexName;
  508.             if (parentObject.overAction != "") parentObject.overAction += ",";
  509.             parentObject.overAction += "'"+hexName+"'";
  510.         } 
  511.         if (curBehavior.event == kEventMouseOut) {
  512.             if (parentObject.csout != "") parentObject.csout += ",";
  513.             parentObject.csout += hexName;
  514.             if (parentObject.outAction != "") parentObject.outAction += ",";
  515.             parentObject.outAction += "'"+hexName+"'";
  516.         } else if (curRestore) {
  517.             hexName = (curBehavior.id+1).toString(16);
  518.             var curAction = "CSAct['" + hexName + "'] = new Array(CSSetStatus,";
  519.             curAction += "' ');\n";
  520.             csAct += curAction;
  521.             // <csaction name="B2C231A71" class="Set Status" val0=" ">
  522.             curAction = "            <csaction name=\"" + hexName + "\" class=\"Set Status\" val0=\" \">\n"
  523.             csactionsStr += curAction;
  524.             if (parentObject.csout != "") parentObject.csout += ",";
  525.             parentObject.csout += hexName;
  526.             if (parentObject.outAction != "") parentObject.outAction += ",";
  527.             parentObject.outAction += "'"+hexName+"'";
  528.         }
  529.     }
  530.     if (IsSwap(curBehavior)) {
  531.         var swapRow = curBehavior.targetRowNum;
  532.         var swapCol = curBehavior.targetColumnNum;
  533.         var swapTable = curBehavior.targetTable;
  534.  
  535.         var curRestore = DoRestore(curBehavior);
  536.         var swapFrame = curBehavior.targetFrameNum; 
  537.         var fileName;
  538.         if (curBehavior.hasHref) {
  539.             fileName = curBehavior.href;
  540.         } else {
  541.             fileName = dirPath + swapTable[swapRow][swapCol].getFrameFileName(swapFrame) + swapTable[swapRow][swapCol].imageSuffix;
  542.         }
  543.         var hexName = curBehavior.id.toString(16);
  544.         var cellName = CellName(swapTable, swapRow,swapCol);
  545.         //CSAct['B2DB1B0B1'] = new Array(CSSetImageURL,'RalphTheImage_mtv',/*URL*/ 'mtv_F3.gif');
  546.         /* Generate a csact entry */
  547.         var curAction = "CSAct['" + hexName + "'] = new Array(CSSetImageURL,";
  548.         // target name
  549.         curAction += "'" + cellName + "',/*URL*/ '" + fileName + "');\n";
  550.         csAct += curAction;
  551.         // <csaction name="B2DB1B0B1" class="Set Image URL" val0="RalphTheImage_mtv" val1="mtv_F3.gif">
  552.         curAction = "            <csaction name=\"" + hexName + "\" class=\"Set Image URL\" val0=\"" ;
  553.         curAction += cellName+"\" val1=\"" + fileName + "\">\n"
  554.         csactionsStr += curAction;
  555.         if (curBehavior.event == kEventMouseOver) {
  556.             if (parentObject.csover != "") parentObject.csover += ",";
  557.             parentObject.csover += hexName;
  558.             if (parentObject.overAction != "") parentObject.overAction += ",";
  559.             parentObject.overAction += "'"+hexName+"'";
  560.         } 
  561.         if (curBehavior.event == kEventOnClick) {
  562.             if (parentObject.csclick != "") parentObject.csclick += ",";
  563.             parentObject.csclick += hexName;
  564.             if (parentObject.clickAction != "") parentObject.clickAction += ",";
  565.             parentObject.clickAction += "'"+hexName+"'";
  566.         }
  567.         if (curBehavior.event == kEventMouseOut) {
  568.             if (parentObject.csout != "") parentObject.csout += ",";
  569.             parentObject.csout += hexName;
  570.             if (parentObject.outAction != "") parentObject.outAction += ",";
  571.             parentObject.outAction += "'"+hexName+"'";
  572.         } else if (curRestore) {
  573.             hexName = (curBehavior.id+1).toString(16);
  574.             fileName = dirPath + swapTable[swapRow][swapCol].getFrameFileName(0) + swapTable[swapRow][swapCol].imageSuffix;
  575.             /* Generate a csact entry */
  576.             var curAction = "CSAct['" + hexName + "'] = new Array(CSSetImageURL,";
  577.             // target name
  578.             curAction += "'" + cellName + "',/*URL*/ '" + fileName + "');\n";
  579.             csAct += curAction;
  580.             // <csaction name="B2DB1B0B1" class="Set Image URL" val0="RalphTheImage_mtv" val1="mtv_F3.gif">
  581.             curAction = "            <csaction name=\"" + hexName + "\" class=\"Set Image URL\" val0=\"" ;
  582.             curAction += cellName+"\" val1=\"" + fileName + "\">\n"
  583.             csactionsStr += curAction;
  584.             if (parentObject.csout != "") parentObject.csout += ",";
  585.             parentObject.csout += hexName;
  586.             if (parentObject.outAction != "") parentObject.outAction += ",";
  587.             parentObject.outAction += "'"+hexName+"'";
  588.         }
  589.             
  590.     }
  591. }
  592.  
  593.  
  594. function DoSlicesThatAreNotButtons(curSlices) {
  595.     // Handle not button and imagemap actions.
  596.     for (var curRow = 0; curRow < curSlices.numRows; curRow++) {
  597.         for (var curCol = 0; curCol < curSlices.numColumns; curCol++) {
  598.             var curSlice = curSlices[curRow][curCol];
  599.             if (curSlice.skipCell) continue; 
  600.             var nestedTable = curSlices[curRow][curCol].nestedTableSlices;
  601.             if (nestedTable) {
  602.                 DoSlicesThatAreNotButtons(nestedTable);
  603.                 continue;
  604.             }
  605.  
  606.             if (curSlice.isButton) continue;
  607.             curSlice.overAction = "";
  608.             curSlice.outAction = "";
  609.             curSlice.clickAction = "";
  610.             curSlice.csover = "";
  611.             curSlice.csout = "";
  612.             curSlice.csclick = "";
  613.             var cellName = CellName(curSlices, curRow,curCol);    
  614.             var behaviors =curSlice.behaviors;
  615.             for (var i=0; i<behaviors.numberOfBehaviors; i++) {
  616.                 var curBehavior = behaviors[i];
  617.                 DoBehavior(curSlices, curBehavior, curSlice);
  618.             }
  619.             curSlice.hasJavascript = curSlice.overAction != "" || curSlice.outAction != "" || curSlice.clickAction != "";
  620.             var imagemap = curSlice.imagemap;
  621.             for (var j=0; j < imagemap.numberOfURLs; j++) {
  622.                 var curImagemap = imagemap[j];
  623.                 curImagemap.overAction = "";
  624.                 curImagemap.outAction = "";
  625.                 curImagemap.clickAction = "";
  626.                 curImagemap.csover = "";
  627.                 curImagemap.csout = "";
  628.                 curImagemap.csclick = "";
  629.                 var modBehaviors = curImagemap.modBehaviors;
  630.                 for (var i=0; i<modBehaviors.numberOfBehaviors; i++) {
  631.                     var curBehavior = modBehaviors[i];
  632.                     DoBehavior(curSlices, curBehavior, curImagemap);
  633.                 }
  634.             }
  635.         }
  636.     }        
  637. }
  638.  
  639. DoSlicesThatAreNotButtons(slices);
  640.  
  641. var Name = 0;
  642. WRITE_HTML("\n");
  643. if (doHeader) {
  644.     WRITE_HTML("CSAg = window.navigator.userAgent;" + "CSBVers = parseInt" + "(CSAg.charAt" + "(CSAg.indexOf");
  645.     WRITE_HTML("(");
  646.     WRITE_HTML("\"");
  647.     WRITE_HTML("/");
  648.     WRITE_HTML("\")+1),10);\n");
  649. }
  650.  
  651. function IsIE(){ return CSAg.indexOf("MSIE") > 0;}
  652. function CSIEStyl(s) { return document.all.tags("div")[s].style; }
  653. function CSNSStyl(s){ return CSFindElement(s,0); }
  654. function CSFindElement(n,ly) {
  655. if (CSBVers < 4) return document[n]; 
  656. var curDoc = ly ? ly.document : document; var elem = curDoc[n];
  657.     if (!elem) { for (var i=0;i<curDoc.layers.length;i++) {
  658.         elem = CSFindElement(n,curDoc.layers[i]); if (elem) return elem; }}
  659.         return elem;
  660.     }
  661. function CSButtonReturn () {
  662.     var bAgent = window.navigator.userAgent; 
  663.     var bAppName = window.navigator.appName;
  664.     if ((bAppName.indexOf("Explorer") >= 0) && (bAgent.indexOf("Mozilla/3") >= 0) && (bAgent.indexOf("Mac") >= 0))
  665.     return false; // follow link
  666.     else return true; // follow link
  667. }
  668. function CSClickReturn () {
  669.     var bAgent = window.navigator.userAgent; 
  670.     var bAppName = window.navigator.appName;
  671.     if ((bAppName.indexOf("Explorer") >= 0) && (bAgent.indexOf("Mozilla/3") >= 0) && (bAgent.indexOf("Mac") >= 0))
  672.     return false; // follow link
  673.     else return true; // follow link
  674. }
  675. function CSIShow(n,i) {
  676.     if (document.images) {
  677.         if (CSIm[n]) {
  678.         var img = (!IsIE()) ? CSFindElement(n,0) : document[n];
  679.         if (img) {img.src = CSIm[n][i].src; self.status = CSIm[n][3];}
  680.         return true;
  681.         }
  682.     }
  683.     return false;
  684. }
  685. function CSILoad(im,ar) {
  686.     if (document.images) {
  687.         CSIm[im] = new Object();
  688.         for (var i=0;i<3;i++) {
  689.             if (ar[i] != '') { CSIm[im][i] = new Image(); CSIm[im][i].src = ar[i]; }
  690.             else CSIm[im][i] = 0;
  691.         }
  692.         CSIm[im][3] = ar[3];
  693.     }
  694. }
  695. function CSAction(array) { 
  696.     var result;
  697.     for (var i=0;i<array.length;i++) {
  698.         result = CSAct[array[i]][0](CSAct[array[i]]); 
  699.     }
  700.     return result;
  701. }
  702. function CSSetImageURL(action) {
  703.     var img = null;
  704.     if (document.images) {
  705.         if (!IsIE()) img = CSFindElement(action[1],0);
  706.         else img = document.images[action[1]];
  707.         if (img) img.src = action[2];
  708.     }
  709. }
  710. function CSSetStatus(action) { self.status = action[1]; }
  711.  
  712. if (doHeader) {
  713.  
  714.     WRITE_HTML(IsIE);
  715.     WRITE_HTML(CSIEStyl);
  716.     WRITE_HTML(CSNSStyl);
  717.     WRITE_HTML(CSFindElement);
  718.     WRITE_HTML(CSButtonReturn);
  719.     WRITE_HTML(CSClickReturn);
  720.     WRITE_HTML("CSIm = new Object();\n");
  721.     WRITE_HTML(CSIShow);
  722.     WRITE_HTML(CSILoad);
  723.     WRITE_HTML(CSAction);
  724.     if (csAct != "") {
  725.         WRITE_HTML("CSAct = new Object;\n");
  726.     }
  727.  
  728.     WRITE_HTML(CSSetImageURL);
  729.     WRITE_HTML(CSSetStatus);
  730.  
  731.     if (needsPreloads) {
  732.         WRITE_HTML("CSImages=new Array();\n");
  733.         function CSPreloadImage(action) {
  734.             if (document.images) { CSImages[CSImages.length]=new Image(); CSImages[CSImages.length-1].src=action[1]; }
  735.         }
  736.         WRITE_HTML(CSPreloadImage);
  737.     }
  738.  
  739.     if (csAct != "") {
  740.         WRITE_HTML(csAct);
  741.     }
  742.  
  743.     WRITE_HTML("// --></script>\n</csscriptdict>\n");
  744.     if (csactionsStr != "") {
  745.         WRITE_HTML("<csactions>\n");
  746.         WRITE_HTML(csactionsStr);
  747.         WRITE_HTML("</csactions>\n");
  748.     }
  749.  
  750.     WRITE_HTML(csactionItem);
  751.  
  752.     WRITE_HTML("</head>\n\n");
  753. }
  754.  
  755. //$JS
  756.  
  757.  
  758. function DoImagemap(curSlice) {
  759.     if (curSlice.skipCell)
  760.         return; 
  761.     if (curSlice.hasImagemap) {
  762.         if (curSlice.isButton) {
  763.             alert("Slice "+curRow+","+curCol+" is a button!  With Imagemap!  OOPS!");
  764.         }
  765.         // Write the image map.
  766.         var imageName = curSlice.getFrameFileName(0);
  767.         WRITE_HTML("<map name=\"m_", imageName, "\">");
  768.         
  769.         var i = 0;
  770.         while (i < curSlice.imagemap.numberOfURLs) {
  771.             var curImagemap = curSlice.imagemap[i];
  772.  
  773.             // Write the area tag with shape definitions.
  774.             WRITE_HTML("<area shape=\"");
  775.             WRITE_HTML(curImagemap.shape); // Shapes are rect poly and circle
  776.             WRITE_HTML("\" coords=\"");
  777.             for (var j=0; j<curImagemap.numCoords; j++) {
  778.                 if (j>0) WRITE_HTML(",");
  779.                 // polygon has n coords.
  780.                 // rect has 2 coords, topLeft, and botomRight.
  781.                 // Circle has one coord, center; plus radius.
  782.                 WRITE_HTML((curImagemap.xCoord(j)-curSlice.left), ",", (curImagemap.yCoord(j)-curSlice.top)); 
  783.             }
  784.             if (curImagemap.shape == "circle") {
  785.                 // Write the radius for circle hotspots.
  786.                 WRITE_HTML(", ", curImagemap.radius);
  787.             }
  788.             WRITE_HTML("\"");
  789.             var href = " href=\"#\"";
  790.             if (curImagemap.hasHref) {
  791.                 href = " href=\"";
  792.                 href += curImagemap.href;
  793.                 href += "\"";
  794.                 if (curImagemap.hasTargetText) {
  795.                     href += " target=\"";
  796.                     href += curImagemap.targetText;
  797.                     href += "\"";
  798.                 }
  799.             }
  800.  
  801.             WRITE_HTML(href);
  802.  
  803.             // Write alt text for hotspot.
  804.             var altText = "";
  805.             if (curImagemap.hasAltText) {
  806.                 altText = curImagemap.altText;
  807.             } else {
  808.                 altText = exportDoc.altText;
  809.             }
  810.  
  811.             if (altText!="") {
  812.                 WRITE_HTML(" title=\"", altText, "\"");
  813.                 WRITE_HTML(" alt=\"", altText, "\"");
  814.             }
  815.             
  816.             if (curImagemap.overAction) {
  817.                 WRITE_HTML(" onmouseover=\"");
  818.                 WRITE_HTML("CSAction(new Array(" + curImagemap.overAction + "));");
  819.                 WRITE_HTML("return true;");
  820.                 WRITE_HTML("\"");
  821.                 WRITE_HTML(" csover=\"" + curImagemap.csover + "\"");
  822.             }
  823.             
  824.             if (curImagemap.outAction) {
  825.                 WRITE_HTML(" onmouseout=\"");
  826.                 WRITE_HTML("CSAction(new Array(" + curImagemap.outAction + "));");
  827.                 WRITE_HTML("return true;");
  828.                 WRITE_HTML("\"");
  829.                 WRITE_HTML(" csout=\"" + curImagemap.csout + "\"");
  830.             }
  831.             
  832.             if (curImagemap.clickAction) {
  833.                 WRITE_HTML(" onclick=\"");
  834.                 WRITE_HTML("CSAction(new Array(" + curImagemap.clickAction + "));");
  835.                 WRITE_HTML("return CSClickReturn();");
  836.                 WRITE_HTML("\"");
  837.                 WRITE_HTML(" csclick=\"" + curImagemap.csclick + "\"");
  838.             }
  839.  
  840.             WRITE_HTML(">");
  841.             i++;
  842.         } 
  843.         gotJavascript = curSlice.overAction || curSlice.outAction || curSlice.clickAction; 
  844.         // If the current slice had a URL attached, it was moved and written here.
  845.         var link = "";
  846.         if (curSlice.hasHref) {
  847.             link = curSlice.href;
  848.         } else {  
  849.             if (exportDoc.backgroundLink) {
  850.                 link = exportDoc.backgroundLink.href;
  851.             }
  852.         }
  853.  
  854.         // If the current slice had a URL attached, it was moved and written here.
  855.         if (gotJavascript || link != "") {
  856.             WRITE_HTML("<area shape=\"rect\" coords=\"0,0, ", curSlice.width, ",", curSlice.height, "\" ");
  857.             var href="#";
  858.             if (link && link!="") {
  859.                 href = link;
  860.             }
  861.             WRITE_HTML("href=\"", href, "\"");
  862.             if (curSlice.hasTargetText) {
  863.                 WRITE_HTML("\n  target=\"", curSlice.targetText, "\"");
  864.             }
  865.             if (curSlice.overAction) {
  866.                 WRITE_HTML(" onmouseover=\"");
  867.                 WRITE_HTML("CSAction(new Array(" + curSlice.overAction + "));");
  868.                 WRITE_HTML("return true;");
  869.                 WRITE_HTML("\"");
  870.                 WRITE_HTML(" csover=\"" + curSlice.csover + "\"");
  871.             }
  872.             
  873.             if (curSlice.outAction) {
  874.                 WRITE_HTML(" onmouseout=\"");
  875.                 WRITE_HTML("CSAction(new Array(" + curSlice.outAction + "));");
  876.                 WRITE_HTML("return true;");
  877.                 WRITE_HTML("\"");
  878.                 WRITE_HTML(" csout=\"" + curSlice.csout + "\"");
  879.             }
  880.             
  881.             if (curSlice.clickAction) {
  882.                 WRITE_HTML(" onclick=\"");
  883.                 WRITE_HTML("CSAction(new Array(" + curSlice.clickAction + "));");
  884.                 WRITE_HTML("return CSClickReturn();");
  885.                 WRITE_HTML("\"");
  886.                 WRITE_HTML(" csclick=\"" + curSlice.csclick + "\"");
  887.             }
  888.  
  889.             var altText = "";
  890.             if (curSlice.hasAltText) {
  891.                 altText = curSlice.altText;
  892.             } else {
  893.                 altText = exportDoc.altText;
  894.             }
  895.             if (altText!="") {
  896.                 WRITE_HTML(" title=\"", altText, "\"");
  897.                 WRITE_HTML(" alt=\"", altText, "\"");
  898.             }
  899.             WRITE_HTML(">");
  900.         }    
  901.         WRITE_HTML("</map>");
  902.         //WRITE_HTML("\n");
  903.     }
  904. }
  905.  
  906.  
  907. if (doHeader) {
  908.  
  909.     WRITE_HTML("<body bgcolor=\"#", exportDoc.backgroundColor.toString(), "\"");
  910.     if (hasAnyButtons) {
  911.         WRITE_HTML(" onload=\"CSScriptInit();\"");
  912.     }
  913.     WRITE_HTML(">\n");
  914.  
  915.     WRITE_HTML("\n");
  916. }
  917.  
  918.  
  919. function WriteTable(curSlices, indent) {
  920.     var needTable = curSlices.numRows > 1 || curSlices.numColumns > 1;
  921.     var curCol;
  922.     var curRow;
  923.     var downIndex = 0;
  924.     if (needTable) {
  925.         WRITE_HTML("<table ");
  926.  
  927.         // If the Fireworks document's canvas is not transparent and the Include undefined curSlices checkbox
  928.         // is off, give the table a background color based on the FIreworks document's canvas color.
  929.         if (!exportDoc.backgroundIsTransparent && curSlices.doSkipUndefined) {
  930.             WRITE_HTML("bgcolor=\"#", exportDoc.backgroundColor, "\"");
  931.         } 
  932.  
  933.         WRITE_HTML("border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"",
  934.                 curSlices.width, "\">\n");
  935.  
  936.         /* This is the magic comment for html update. */
  937.         if (indent == "") {
  938.             //<--- fwtable fwsrc="mydoc" fwbase="basename" --->
  939.             var comment = "<!-- fwtable fwsrc=\"" + exportDoc.docSaveName + "\" fwbase=\"" + exportDoc.filename + "\"" + " -->\n";
  940.             WRITE_HTML(comment);
  941.         }
  942.  
  943.  
  944.         if (curSlices.doShimEdges) {
  945.             WRITE_HTML("  <tr>");
  946.             for (curCol = 0; curCol < curSlices.numColumns; curCol++) {
  947.                 WRITE_HTML("   <td><img src=\"", curSlices.shimPath, "\" width=\"", 
  948.                     curSlices[0][curCol].cellWidth, "\" height=\"1\" border=\"0\"></td>\n"); 
  949.             }
  950.             WRITE_HTML("   <td><img src=\"", curSlices.shimPath, "\" width=\"1", 
  951.                 "\" height=\"1\" border=\"0\"></td>\n"); 
  952.             WRITE_HTML("  </tr>\n");
  953.         }
  954.     }
  955.  
  956.     for (curRow = 0; curRow < curSlices.numRows; curRow++) {
  957.         
  958.         if (needTable) {
  959.             WRITE_HTML(indent+"  <tr valign=\"top\">");
  960.             WRITE_HTML_COMMENT(" row "+(curRow+1)+" ");
  961.         }
  962.         
  963.         for (curCol = 0; curCol < curSlices.numColumns; curCol++) {
  964.         
  965.             var curSlice = curSlices[curRow][curCol];
  966.             if (curSlice.skipCell) continue;   
  967.  
  968.  
  969.             // Write rowspan and colspan if necessary. Ex: rowspan="1" colspan="3"
  970.             if (needTable) {
  971.                 // Write rowspan and colspan if necessary. Ex: rowspan="1" colspan="3"
  972.                 WRITE_HTML(indent+"   <td");
  973.                 if (curSlice.rowSpan > 1) {
  974.                     WRITE_HTML(" rowspan=\"", curSlice.rowSpan,"\"");
  975.                 }
  976.                 if (curSlice.columnSpan>1) {
  977.                     WRITE_HTML(" colspan=\"", curSlice.columnSpan, "\"");
  978.                 }
  979.                 WRITE_HTML(">");
  980.             }
  981.             
  982.             var suffix = "";
  983.             var cellName = exportDoc.imagename + "_" + (curRow+1) + "_" + (curCol+1);
  984.             
  985.             var nestedTable = curSlice.nestedTableSlices;
  986.             if (nestedTable) {
  987.                 WriteTable(nestedTable, "    "+indent);
  988.                 if (needTable) {
  989.                     WRITE_HTML("</td>");
  990.                 }
  991.                 WRITE_HTML("\n");
  992.                 continue;
  993.             }
  994.  
  995.             // Write HTML text from curSlices set to "Text (No Image)"
  996.             if (!curSlice.hasImage) {
  997.                 // no image, just dump out html text.
  998.                 if (curSlice.htmlText) {
  999.                     WRITE_HTML(curSlice.htmlText);
  1000.                 } else if (needTable) {
  1001.                     if (curSlices.shimPath) {
  1002.                         WRITE_HTML("<img src=\"",
  1003.                             curSlices.shimPath, "\" width=\"", curSlice.width, "\" height=\"", 
  1004.                             curSlice.height, "\" border=\"0\">"); 
  1005.                     }
  1006.                 }
  1007.                 if (needTable) WRITE_HTML("</td>\n");
  1008.                 continue;
  1009.             }
  1010.  
  1011.             // If current slice is not defined by a slice object and Export Undefined
  1012.             // curSlices is not checked, don't output an image and if Shims are specified 
  1013.             // place a shim image in the current cel
  1014.             if (curSlice.isUndefined && curSlices.doSkipUndefined) {
  1015.                 if (needTable) {
  1016.                     if (curSlices.shimPath) {
  1017.                         WRITE_HTML("<img src=\"",
  1018.                             curSlices.shimPath, "\" width=\"", curSlice.width, "\" height=\"", 
  1019.                             curSlice.height, "\" border=\"0\">"); 
  1020.                     }
  1021.                     WRITE_HTML("</td>\n");
  1022.                 }
  1023.                 // Tell Fireworks to not write the image file. Setting the filename to "" forces 
  1024.                 // Fireworks to not generate the image.
  1025.                 var q;
  1026.                 for (q=0; q<exportDoc.numFrames; q++) {
  1027.                     curSlice.setFrameFileName(q, "");
  1028.                 }    
  1029.                 continue;
  1030.             }
  1031.             
  1032.             var cellName = CellName(curSlices, curRow, curCol);            
  1033.             var button = new Object;
  1034.             button.name = cellName;
  1035.             var upFrame = 0;
  1036.             if (slices.doDemoHTML && slices.demoIndex>0 && 
  1037.                 slices.demoIndex == curSlice.downIndex) {
  1038.                 upFrame = 2;
  1039.             } 
  1040.  
  1041.             button.up = dirPath + curSlice.getFrameFileName(upFrame) + curSlice.imageSuffix
  1042.             button.over = "";
  1043.             button.hit = "";
  1044.             
  1045.             var behaviors = curSlice.behaviors;
  1046.             for (var i=0; i<behaviors.numberOfBehaviors; i++) {
  1047.                 var curBehavior = behaviors[i];
  1048.                 if (IsSwap(curBehavior)) {
  1049.                     var swapRow = curBehavior.targetRowNum;
  1050.                     var swapCol = curBehavior.targetColumnNum;
  1051.                     var swapTable = curBehavior.targetTable;
  1052.                     if (swapRow != curRow || swapCol != curCol || swapTable != curSlices) continue;
  1053.                     if (!curBehavior.ateTheBehavior) continue;
  1054.                     if (curBehavior.hasHref) {
  1055.                         fileName = curBehavior.href;
  1056.                     } else {
  1057.                         fileName = dirPath + curSlice.getFrameFileName(curBehavior.targetFrameNum) + curSlice.imageSuffix;
  1058.                     }
  1059.                     if (curBehavior.event == kEventMouseOver) {
  1060.                         button.over = fileName;
  1061.                     } 
  1062.                     if (curBehavior.event == kEventOnClick) {
  1063.                         button.hit = fileName;
  1064.                     } 
  1065.                     
  1066.                 }
  1067.             }
  1068.             var isButton = curSlice.isButton;        
  1069.  
  1070.             if (!isButton && (curSlice.hasImagemap || !curSlice.hasJavascript) ){
  1071.                 var imageName = curSlice.getFrameFileName(0); 
  1072.                 if (slices.doDemoHTML && slices.demoIndex>0 && 
  1073.                     slices.demoIndex == curSlice.downIndex) {
  1074.                     imageName = curSlice.getFrameFileName(2);
  1075.                 } 
  1076.                 var altText = "";
  1077.                 if (curSlice.hasAltText) {
  1078.                     altText = curSlice.altText;
  1079.                 } else {
  1080.                     altText = exportDoc.altText;
  1081.                 }
  1082.                 //  <img name="n_03_02" src="File_03_02.gif" width="79" height="71" border="0"
  1083.                 WRITE_HTML("<img name=\"", cellName, "\" src=\"",
  1084.                     dirPath, imageName, curSlice.imageSuffix, "\" width=\"",
  1085.                     curSlice.width,"\" height=\"", curSlice.height, "\" border=\"0\"");
  1086.                 if (altText != "") {
  1087.                     WRITE_HTML(" alt=\"", altText, "\"");
  1088.                 }
  1089.                 if (curSlice.hasImagemap) {
  1090.                     WRITE_HTML(" usemap=\"#m_",imageName,"\""); 
  1091.                 }
  1092.                 WRITE_HTML(">");
  1093.                 if (curSlice.hasImagemap) DoImagemap(curSlice);    
  1094.                 if (needTable) WRITE_HTML("</td>\n");    
  1095.                 continue;
  1096.             }
  1097.                     
  1098.             if (isButton) {    
  1099.                 WRITE_HTML("        <csobj w=\"");
  1100.                 WRITE_HTML(curSlice.width);
  1101.                 WRITE_HTML("\" ");
  1102.                 WRITE_HTML("h=\"");
  1103.                 WRITE_HTML(curSlice.height);
  1104.                 WRITE_HTML("\"");
  1105.                 WRITE_HTML(" t=\"Button\" ");
  1106.                 if (button.over != "") {
  1107.                     WRITE_HTML(" ht=\"");
  1108.                     WRITE_HTML(button.over);
  1109.                     WRITE_HTML("\"");
  1110.                 }
  1111.                 if (button.hit != "") {
  1112.                     WRITE_HTML(" cl=\"");
  1113.                     WRITE_HTML(button.hit);
  1114.                     WRITE_HTML("\"");
  1115.                 }
  1116.  
  1117.                 if (curSlice.csover != "") {
  1118.                     WRITE_HTML(" csover=\"" + curSlice.csover + "\"");
  1119.                 }
  1120.                 if (curSlice.csclick != "") {
  1121.                     WRITE_HTML(" csclick=\"" + curSlice.csclick + "\"");
  1122.                 }
  1123.                 if (curSlice.csout != "") {
  1124.                     WRITE_HTML(" csout=\"" + curSlice.csout + "\"");
  1125.                 }
  1126.                 WRITE_HTML(">");
  1127.             }
  1128.  
  1129.             // Write link if slice has URL attached.
  1130.             var href = "href=\"#\"";
  1131.             var hasHref = curSlice.hasHref;
  1132.             if (curSlice.hasHref) {
  1133.                 href = "href=\"";
  1134.                 href += curSlice.href;
  1135.                 href += "\"";
  1136.                 if (curSlice.hasTargetText) {
  1137.                     href += " target=\"";
  1138.                     href += curSlice.targetText;
  1139.                     href += "\"";
  1140.                 }
  1141.                 
  1142.             } else {
  1143.                 var link = "";
  1144.                 if (exportDoc.backgroundLink) {
  1145.                     link = exportDoc.backgroundLink.href;
  1146.                 }
  1147.                 if (link != "") {
  1148.                     hasHref = true;
  1149.                     href = "href=\"" + link +"\"";
  1150.                 }
  1151.             }
  1152.  
  1153.             if (slices.doDemoHTML && curSlice.downIndex>0) {
  1154.                 href = "href=\"" + slices.demoHref(curSlice.downIndex) +".htm\"";
  1155.             }
  1156.             WRITE_HTML("<a " + href);
  1157.             WRITE_HTML("\"");
  1158.             
  1159.             var mouseOver = curSlice.overAction || isButton;
  1160.             if (mouseOver) {
  1161.                 WRITE_HTML(" onmouseover=\"");
  1162.                 if (curSlice.overAction) {
  1163.                     WRITE_HTML("CSAction(new Array(" + curSlice.overAction + "));");
  1164.                 }
  1165.                 if (isButton) {
  1166.                     WRITE_HTML("return CSIShow(");
  1167.                     WRITE_HTML("'");
  1168.                     WRITE_HTML(button.name);
  1169.                     WRITE_HTML("',1)");
  1170.                 } else {
  1171.                     WRITE_HTML("return true;");
  1172.                 }
  1173.                 WRITE_HTML("\" ");
  1174.             }
  1175.             
  1176.             var mouseOut = curSlice.outAction || isButton;
  1177.             if (mouseOut) {
  1178.                 WRITE_HTML(" onmouseout=\"");
  1179.                 if (curSlice.outAction) {
  1180.                     WRITE_HTML("CSAction(new Array(" + curSlice.outAction + "));");
  1181.                 }
  1182.                 if (isButton) {
  1183.                     WRITE_HTML("return CSIShow(");
  1184.                     WRITE_HTML("'");
  1185.                     WRITE_HTML(button.name);
  1186.                     WRITE_HTML("',0)");
  1187.                 } else {
  1188.                     WRITE_HTML("return true;");
  1189.                 }
  1190.                 WRITE_HTML("\" ");
  1191.             }
  1192.             
  1193.             var clickButton = isButton && button.hit != "";
  1194.             var click = curSlice.clickAction || clickButton;
  1195.             if (click) {
  1196.  
  1197.                 WRITE_HTML("onclick=\"");
  1198.                 if (curSlice.clickAction) {
  1199.                     WRITE_HTML("CSAction(new Array(" + curSlice.clickAction + "));");
  1200.                 }
  1201.                 if (clickButton) {    
  1202.                     WRITE_HTML("CSIShow('");
  1203.                     WRITE_HTML(button.name);
  1204.                     WRITE_HTML("',2)");
  1205.                     WRITE_HTML(";return CSButtonReturn()");
  1206.                 } else {
  1207.                     WRITE_HTML("return(true);");
  1208.                 }
  1209.                 WRITE_HTML("\"");
  1210.             }
  1211.             if (!isButton) {
  1212.                 if (curSlice.csover != "") {
  1213.                     WRITE_HTML(" csover=\"" + curSlice.csover + "\"");
  1214.                 }
  1215.                 if (curSlice.csclick != "") {
  1216.                     WRITE_HTML(" csclick=\"" + curSlice.csclick + "\"");
  1217.                 }
  1218.                 if (curSlice.csout != "") {
  1219.                     WRITE_HTML(" csout=\"" + curSlice.csout + "\"");
  1220.                 }
  1221.             }
  1222.             WRITE_HTML(">");
  1223.             
  1224.             var imageName = curSlice.getFrameFileName(0); 
  1225.             if (slices.doDemoHTML && slices.demoIndex>0 && 
  1226.                 slices.demoIndex == curSlice.downIndex) {
  1227.                 imageName = curSlice.getFrameFileName(2);
  1228.             } 
  1229.             var altText = curSlice.buttonStatus;
  1230.             
  1231.             //  <img name="n_03_02" src="File_03_02.gif" width="79" height="71" border="0"
  1232.             WRITE_HTML("<img name=\"", cellName, "\" src=\"",
  1233.                 dirPath, imageName, curSlice.imageSuffix, "\" width=\"",
  1234.                 curSlice.width,"\" height=\"", curSlice.height, "\" border=\"0\"");
  1235.             if (curSlice.hasImagemap) {
  1236.                 // usemap="#$NM" ismap      
  1237.                 WRITE_HTML(" usemap=\"#m_", imageName, "\""); 
  1238.             }
  1239.             if (altText != "") {
  1240.                 WRITE_HTML(" alt=\"", altText, "\"");
  1241.             }
  1242.             
  1243.             WRITE_HTML(">");    
  1244.  
  1245.             
  1246.             WRITE_HTML("</a>");
  1247.             if (isButton) WRITE_HTML("</csobj>");
  1248.             if (needTable) WRITE_HTML("</td>\n");
  1249.         }    
  1250.             
  1251.         if (needTable) {
  1252.             if (curSlices.doShimEdges) {
  1253.                 /* Write the 1 pixel transparent shim. */
  1254.                 WRITE_HTML("    <td><img src=\"",
  1255.                     curSlices.shimPath, "\" width=\"1\" height=\"", 
  1256.                     curSlices[curRow][0].cellHeight, "\" border=\"0\"></td>\n"); 
  1257.             }
  1258.             WRITE_HTML(indent+"  </tr>\n");
  1259.         }
  1260.     }
  1261.     if (needTable) {
  1262.         // Close table.
  1263.         WRITE_HTML(indent+"</table>");
  1264.     }
  1265. }
  1266.  
  1267. WriteTable(slices, "");
  1268.  
  1269. WRITE_HTML("\n");
  1270. WRITE_HTML("<!-- This HTML was automatically created with Macromedia Fireworks 3.0 http://www.macromedia.com -->\n");
  1271. WRITE_HTML("\n");
  1272. if (doHeader) {
  1273.     WRITE_HTML("</body>\n");
  1274.     WRITE_HTML("</html>\n");
  1275. }
  1276.  
  1277.  
  1278.  
  1279.